/*
 * @(#)User.java
 * 
 * Create Version: 1.0.0
 * Author: James Liu
 * Create Date: 2009-12-09
 * 
 * Copyright (c) 2009 ASPire Information Technologies Ltd. All Right Reserved.
 */
package com.aspire.boc.mms.wmf.cam;


import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;


/**
 * CAM value object.
 * 
 * @version 1.0.0   2009-12-09
 * @author  James Liu
 */
public class User implements Serializable {
    
    private static final long serialVersionUID = -8613652727106096143L;
    
    private int id;
    private String name;
    private String realName;
    private int sex;
    private Date birthDate;
    private boolean state4Bool;
    private String mobile;
    private String email;
    private Date enrollDate;
    private Date lastUpdateDate;
    
    private Set<Group> groups = new LinkedHashSet<Group>();
    private Set<Role> roles = new LinkedHashSet<Role>();
    
    
    public int getId() {
    
        return id;
    }
    
    public void setId(int id) {
    
        this.id = id;
    }
    
    public String getName() {
    
        return name;
    }
    
    public void setName(String name) {
    
        this.name = name;
    }
    
    public String getRealName() {
    
        return realName;
    }
    
    public void setRealName(String realName) {
    
        this.realName = realName;
    }
    
    public int getSex() {
    
        return sex;
    }
    
    public void setSex(int sex) {
    
        this.sex = sex;
    }
    
    public Date getBirthDate() {
    
        return birthDate;
    }
    
    public void setBirthDate(Date birthDate) {
    
        this.birthDate = birthDate;
    }
    
    public boolean isState4Bool() {
    
        return state4Bool;
    }
    
    public void setState4Bool(boolean state4Bool) {
    
        this.state4Bool = state4Bool;
    }
    
    public String getMobile() {
    
        return mobile;
    }
    
    public void setMobile(String mobile) {
    
        this.mobile = mobile;
    }
    
    public String getEmail() {
    
        return email;
    }
    
    public void setEmail(String email) {
    
        this.email = email;
    }
    
    public Date getEnrollDate() {
    
        return enrollDate;
    }
    
    public void setEnrollDate(Date enrollDate) {
    
        this.enrollDate = enrollDate;
    }
    
    public Date getLastUpdateDate() {
    
        return lastUpdateDate;
    }
    
    public void setLastUpdateDate(Date lastUpdateDate) {
    
        this.lastUpdateDate = lastUpdateDate;
    }
    
    public Set<Group> getGroups() {
    
        return groups;
    }
    
    public void setGroups(Set<Group> groups) {
    
        this.groups = groups;
    }
    
    public Set<Role> getRoles() {
    
        return roles;
    }
    
    public void setRoles(Set<Role> roles) {
    
        this.roles = roles;
    }
    
public String toString() {
        
        StringBuilder result = new StringBuilder();
        
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        result.append("User[id=")
              .append(this.getId())
              .append(", name=")
              .append(this.getName())
              .append(", realName=")
              .append(this.getRealName())
              .append(", sex=")
              .append(this.getSex())
              .append(", birthDate=")
              .append((this.getBirthDate() == null) ? "null" : sdf.format(this.getBirthDate()))
              .append(", state4Bool=")
              .append(this.isState4Bool())
              .append(", mobile=")
              .append(this.getMobile())
              .append(", email=")
              .append(this.getEmail())
              .append(", enrollDate=")
              .append((this.getEnrollDate() == null) ? "null" : sdf.format(this.getEnrollDate()))
              .append(", lastUpdateDate=")
              .append((this.getLastUpdateDate() == null) ? "null" : sdf.format(this.getLastUpdateDate()))
              .append(", groupCount=")
              .append(this.getGroups().size())
              .append(", roleCount=")
              .append(this.getRoles().size())
              .append("]");
        
        return result.toString();
    }
}